I had a problem where I couldn’t return an array buffer (binary data) in a SvelteKit load function. You can only return POJOs. The solution is simple though - stringify when encoding and parse when decoding!
// Load function
const stringifiedImage = JSON.stringify(Array.from(new Uint8Array(image)));
return {
stringifiedImage
}
// +page.svelte
export let data;
const parsedImage = JSON.parse(data.stringifiedImage);
Easy!